package com.javabasic.algorithm.leetcode;

/**
 * @author xiongmin
 * @version 0.0.1
 * @description Created by work on 2021/11/2 12:06 上午
 * @see [237. Delete Node in a Linked List](https://leetcode-cn.com/problems/delete-node-in-a-linked-list/)
 */
public class DeleteNodeInALinkedList {

    /**
     * 单向链表在给定的节点位置删除，其实就是将后面的元素往前移
     * @param node
     */
    public void deleteNode(ListNode node) {
        ListNode next;
        while (node.next.next != null) {
            next = node.next;
            node.val = next.val;
            node = next;
        }
        next = node.next;
        node.val = next.val;
        node.next = null;
    }
}
